﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace OopMethod
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Test10();
            Console.Read();
        }

        static void Test1()
        {
            Person person = new Person("张三", 11);
            Console.WriteLine(person.Name);
            Console.WriteLine(person.Age);
        }

        static void Test2()
        {

            Student student = new Student(1, "zhangsan", "打球");
            student.Method2();
        }

        static void Test3()
        {
            Car car = new Car("audi")
            {
                Type = "bmw",
                Year = "2020"
            };

            car.ShowInfo();
        }


        static void Test4()
        {
            Car car = new Car("audi");
            car.Year = "1111";
            string info = car.OutInfo();
            Console.WriteLine(info);
        }

        static void Test5()
        {

            Car car = new Car("奔驰");
            car.Year = "1141";
            car.HasParamNoRet(11);
            int result = car.HasParamHasRet(11);
            Console.WriteLine("result=" + result);
        }


        static void Test6()
        {
            Car car = new Car("沃尔沃");
            Tyre[] results = car.TyreArray();
            foreach (var item in results)
            {
                Console.WriteLine($"轮胎位置：{item.Addr}");
            }
            Console.WriteLine("____________________________________");

            Engine e = car.GetEngine();
            Console.WriteLine(e.Name);


        }

        static void Test7()
        {

            Car car = new Car("夏利");
            car.Year = "1990";

            car.ShowInfo3(1, "11", "12", "13");

        }

        static void Test8()
        {

            // 实例化一个集合对象
            List<string> nameList = new List<string>();

            // 增加元素
            nameList.Add("张三");
            nameList.Add("李四");

            // 获取元素的个数
            Console.WriteLine("当前List的长度是：" + nameList.Count);

            // 集合的初始化器
            List<string> player = new List<string>() { "kebi", "james", "curry" };

            // 集合转换成数据
            string[] res = player.ToArray();


            // 将数组放到这个结构中
            player.AddRange(new string[] { "haga发生", "fasfa范德萨" });

            // 集合添加数组 
            string[] names = { "柯布", "柯南" };


            // 删除其中一个
            player.Remove("haga发生");

            player.AddRange(names);

            // 按照索引删除
            player.RemoveAt(1);


            // 在指定位置插入元素
            player.Insert(1, "张三");  // 在索引1的位置，也就是第二个元素，插入张三



            // 清除所有：
            player.Clear();


        }

        static void Test9()
        {

            List<string> names = new List<string>() {
                "张三",
                "李四",
                "王五",
                "马六"
            };

            List<string> newNames = new List<string>(names);

            foreach (var item in names)
            {

                Console.WriteLine($"{item}");
            }

            foreach (var item in newNames)
            {
                Console.WriteLine($"new-{item}");
            }
          
        }

        static void Test10() { 
        
            Dictionary<string , string> infos = new Dictionary<string, string>() {
                ["张三"] = "喜欢读书",
                ["李四"] = "喜欢唱歌"
            };

            foreach (var item in infos.Keys) {
                Console.WriteLine($"keys:{item}");
            }

            foreach (var item in infos.Values) {
                Console.WriteLine($"values:{item}");
            }

        }

    }
}
